package com.jash.labor.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jash.labor.context.Result;
import com.jash.labor.entity.Station;
import com.jash.labor.entity.StationEnroll;
import com.jash.labor.mapper.StationEnrollMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;

@Service
public class StationEnrollService {
    @Resource
    private StationEnrollMapper stationEnrollMapper;

    public Object add(StationEnroll stationEnroll){
        stationEnroll.setCreatetime((new Timestamp(System.currentTimeMillis())));
        stationEnrollMapper.insert(stationEnroll);
        return Result.SUCCESS;
    }

    public Object edit(StationEnroll stationEnroll){
        stationEnrollMapper.updateById(stationEnroll);
        return Result.SUCCESS;
    }

    public Object queryListPage(Integer stationId,Integer pageNo,Integer pageSize) {
        Page<StationEnroll> page = new Page(pageNo,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("stationId",stationId);
        IPage iPage = stationEnrollMapper.selectPage(page,wrapper);
        return new Result<>(iPage);
    }

    public Object laborQueryStationEnrollList(String content,Integer pageNo,Integer pageSize) {
       Page<HashMap> page = new Page<>(pageNo,pageSize);
        IPage<HashMap> iPage = stationEnrollMapper.laborQueryStationEnrollList(page,content);
        return new Result<>(iPage);
    }
}
